<template>
  <div>
    <div class="my_div">
      <img
        src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
        alt=""
      />
      <p @click="btn" :style="{ backgroundColor: colorStr }">{{ dogName }}</p>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dogImgUrl: {
      type: String,
    },
    dogName: {
      type: String,
    },
  },
  data() {
    return {
      colorStr: "",
      gname: "",
    };
  },
  methods: {
    btn() {
      this.gname = this.dogName;
      //   console.log(this.gname);
      this.colorStr = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      this.$emit("like", this.gname);
    },
  },
};
</script>

<style lang="less" scoped>
.my_div {
  width: 300px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
  height: 200px;
}
</style>
